home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / vidhandl / crt.h < prev    next >
C/C++ Source or Header  |  1999-02-03  |  8KB  |  247 lines

  1. //CRT.H
  2. //Video Handling Functions Header File
  3. //ver 2.0
  4.  
  5. #if !defined (__CRT_H)
  6. #define __CRT_H
  7.  
  8. #if !defined( __DEFS_H)
  9. #include <_defs.h>
  10. #endif
  11.  
  12. #ifndef NULL
  13. #include <_null.h>
  14. #endif
  15.  
  16. #ifdef CRT_FULL
  17. #define SAVECRT
  18. #define RESTORECRT
  19. #define SAVECRTWIN
  20. #define RESTORECRTWIN
  21. #endif
  22.  
  23.     /* * * DATA TYPES * * */
  24.  
  25. struct crtwin
  26.  {
  27.     int left;
  28.     int top;
  29.     int right;
  30.     int bottom;
  31.  };
  32.  
  33. struct crtwin_inp
  34.  {
  35.     char *title; //Title (if s==NULL doesn't print title)
  36.     int tcolor; //Title color
  37.     int fchr;   //character used to fill window internal area
  38.     int fcolor; //internal window area color
  39.     int bcolor; //border color
  40.     int btype;  //border type, same as crtframe
  41.  };
  42.  
  43.     /* * * ENUMS AND DEFINES * * */
  44.  
  45. #if !defined(__COLORS)
  46. #define __COLORS
  47.  
  48. enum CRT_COLORS{
  49.     BLACK,            //dark colors
  50.     BLUE,
  51.     GREEN,
  52.     CYAN,
  53.     RED,
  54.     MAGENTA,
  55.     BROWN,
  56.     LIGHTGRAY,
  57.     DARKGRAY,        //light colors
  58.     LIGHTBLUE,
  59.     LIGHTGREEN,
  60.     LIGHTCYAN,
  61.     LIGHTRED,
  62.     LIGHTMAGENTA,
  63.     YELLOW,
  64.     WHITE,
  65.     BKCOLOR,            //selects background color if multiplied by a dark color
  66.     TEXTBLINK = 128    //text blink bit
  67. };
  68. #else
  69.  
  70. #define BKCOLOR 16
  71. #define TEXTBLINK 128
  72.  
  73. #endif
  74.  
  75. //macros to be used  with setdacpgmode
  76. #define DACPAGE_64 0
  77. #define DACPAGE_16 1
  78.  
  79. //macros to be used with changechar
  80. #define CHANGCHR_NORM 0x1100
  81. #define CHANGCHR_RECALC 0x1110
  82.  
  83.     /* * * GLOBAL VARIABLES * * */
  84.  
  85. extern int _Cdecl vmode_x; //number of columns in text mode (default=80)
  86. extern int _Cdecl vmode_y; //number of rows in text mode (default=25)
  87. extern int _Cdecl vmode_mode; //video mode expected by CRT functions (default=3)
  88. extern int _Cdecl crt_direct; //set BIOS use if != 0. (default=0)
  89. extern int _Cdecl crt_page; //selects the text page that must be used by
  90.                                      //functions
  91. extern int _Cdecl crtwin_just; //used by printsj...
  92. extern struct crtwin _Cdecl crtwin_dta; //used by printsj... and crtwindow
  93.  
  94. extern char far * _Cdecl video_addr; //base VIDEO RAM address
  95. extern const char _Cdecl crtframe_mat[]; //array used by crtframe
  96. extern const char _Cdecl mkline_mat[]; //array used by mkline
  97.  
  98. extern int _Cdecl changechar_height; //used by changechar
  99. extern int _Cdecl changechar_func; //and changecharg
  100. extern int _Cdecl changechar_blk;
  101.  
  102. extern int _Cdecl crt_EVGA_addr; //EGA/VGA adapter base address
  103.     //primary = 3C0h    alternate = 2C0h
  104.  
  105.     /* * * FUNCTIONS * * */
  106.  
  107. #ifdef __cplusplus
  108. extern "C" {
  109. #endif
  110. void        _Cdecl    crt_detect    (int mode);
  111. void        _Cdecl    crt_init        (int mode);
  112. void        _Cdecl    videomode (int newmode);
  113. void         _Cdecl    setcrtmode (int mode);
  114. int         _Cdecl    getcrtmode (void);
  115. void         _Cdecl    setcrtpage (int page);
  116. void        _Cdecl    crt_gotoxy    (int  x, int y );
  117. int        _Cdecl    crt_getxy    (int *x, int *y);
  118. int        _Cdecl    getcrtchar    (int  x,    int y );
  119. int        _Cdecl    getcrtcolor (int  x, int y );
  120. void        _Cdecl    biosprintc  (int chr, int x, int y, int color, int func);
  121. void        _Cdecl    printcn    (int c, int x, int y);
  122. void        _Cdecl    printc    (int c, int x, int y, int color);
  123. void        _Cdecl    changecolor (int x, int y, int color);
  124. void         _Cdecl    printct    (int c, int x, int y, int color, unsigned int type);
  125. void        _Cdecl    printsn    (char *s, int x, int y);
  126. void        _Cdecl    prints    (char *s, int x, int y, int color);
  127. void        _Cdecl    printxy    (char *s, int x, int y, int dx, int dy, int color);
  128. void        _Cdecl    printx    (char *s, int x, int y, int color);
  129. int          _Cdecl    printtext (char *s, int x, int y, int color);
  130. void         _Cdecl    printsj    (char *s, int y, int color);
  131. void         _Cdecl    printsjc (char *s, int y, int color);
  132. int         _Cdecl    printsnf    (int x, int y,                    char *fmt,... );
  133. int         _Cdecl    printsf    (int x, int y, int color,    char *fmt,... );
  134. int         _Cdecl    printxyf (int x, int y, int dx, int dy, int color, char *fmt,... );
  135. int         _Cdecl    printxf    (int x, int y, int color,     char *fmt,... );
  136. int         _Cdecl    printtextf    (int x, int y, int color, char *fmt,... );
  137. int         _Cdecl    printsjf     (int y, int color, char *fmt,... );
  138. int         _Cdecl    printsjcf    (int y, int color, char *fmt,... );
  139. void        _Cdecl    fillscr    (int c, int color);
  140. void         _Cdecl    barcolor (int xi, int yi, int xf, int yf, int color);
  141. void        _Cdecl    fillbar    (int c, int xi, int yi, int xf, int yf, int color);
  142. void         _Cdecl    fillbarw (int c, int color);
  143. void         _Cdecl    fillbox    (int c, int xi, int yi, int xf, int yf, int color, int func);
  144. void        _Cdecl    fillboxw (int c, int color, int func);
  145. void        _Cdecl    crtframe    (int xi, int yi, int xf, int yf, int color, unsigned int type);
  146. void        _Cdecl    crtframew(int color, unsigned int type);
  147. void        _Cdecl    mkline_aux     (int cnt, int var, unsigned int mode, int pos, int color);
  148. void        _Cdecl    mkline        (int cnt, int bgn, int end, int color, unsigned int mode);
  149. void         _Cdecl    crtwindow     (struct crtwin_inp p0);
  150. char far *_Cdecl    savevideo        (char far *s);
  151. char far *_Cdecl    restorevideo    (char far *s);
  152. char far *_Cdecl    savevideowin    (char far *s, int xi, int yi, int xf, int yf);
  153. char far *_Cdecl    restorevideowin(char far *s, int xi, int yi, int xf, int yf);
  154. char far *_Cdecl    savevideow        (char far *s);
  155. char far *_Cdecl    restorevideow    (char far *s);
  156.  
  157.  
  158. #ifdef SAVECRT
  159. char far *_Cdecl    savecrt            (char far *s, int mode);
  160. #define savevideo(s) savecrt(s,0)
  161. #endif
  162.  
  163. #ifdef RESTORECRT
  164. char far *_Cdecl    restorecrt        (char far *s, int mode);
  165. #define restorevideo(s) restorecrt(s,0)
  166. #endif
  167.  
  168. #ifdef SAVECRTWIN
  169. char far *_Cdecl  savecrtwin        (char far *s, int xi, int yi, int xf, int yf, int mode);
  170. char far *_Cdecl    savecrtw            (char far *s, int mode);
  171. #define savevideowin(s,xi,yi,xf,yf) savecrtwin(s,xi,yi,xf,yf,0)
  172. #define savevideow(s) savecrtw(s,0)
  173. #endif
  174.  
  175. #ifdef RESTORECRTWIN
  176. char far *_Cdecl  restorecrtwin    (char far *s, int xi, int yi, int xf, int yf, int mode);
  177. char far *_Cdecl    restorecrtw        (char far *s, int mode);
  178. #define restorevideowin(s,xi,yi,xf,yf) restorecrtwin(s,xi,yi,xf,yf,0)
  179. #define restorevideow(s) restorecrtw(s,0)
  180. #endif
  181.  
  182. void    _Cdecl    setcursorsh (unsigned int shape);
  183. int    _Cdecl    getcursorsh (void);
  184. int     _Cdecl    getpalreg (int regpal);
  185. void     _Cdecl    setpalreg (int regpal, int val);
  186. int     _Cdecl    getbordercolor (void);
  187. void  _Cdecl    setbordercolor (int val);
  188. void  _Cdecl    getdacreg (int dacreg, char *red, char *green, char *blue);
  189. void  _Cdecl    setdacreg (int dacreg, char red, char green, char blue);
  190. void  _Cdecl    setdacpgmode    (int pgmode);
  191. void  _Cdecl    setdacpage        (int page);
  192. int     _Cdecl    getdacpgstate     (void);
  193. void  _Cdecl    setchrboxwidth    (int cmd);
  194. void  _Cdecl    settextblink    (int cmd);
  195. void  _Cdecl    changechar    (unsigned char *fmt, int ind, int qt);
  196. void  _Cdecl    changecharg (unsigned char *fmt, int rows);
  197.  
  198. #ifdef __cplusplus
  199. }
  200. #endif
  201.  
  202. //CRT MACROS
  203.  
  204.     //crtframe macros
  205. #define moldura(xi,yi,xf,yf,color)\
  206.     crtframe(xi,yi,xf,yf,color,0)    //draws a text frame with single outline
  207. #define moldurad(xi,yi,xf,yf,color)\
  208.     crtframe(xi,yi,xf,yf,color,1) //draws a text frame with double outline
  209.  
  210.     //crtframew macros
  211. #define molduraw(color)\
  212.     crtframew(color,0)
  213. #define molduradw(color)\
  214.     crtframew(color,1);
  215.  
  216.     //mkline macros
  217. #define linha_hor(y,xi,xf,color)\
  218.     mkline(y,xi,xf,color,0) //draws a single horizontal line
  219. #define linha_ver(x,yi,yf,color)\
  220.     mkline(x,yi,yf,color,1) //draws a single vertical line
  221. #define linhad_hor(y,xi,xf,color)\
  222.     mkline(y,xi,xf,color,2) //draws a double horizontal line
  223. #define linhad_ver(x,yi,yf,color)\
  224.     mkline(x,yi,yf,color,3) //draws a double horizontal line
  225.  
  226.     //macro setcrtwin
  227. #define setcrtwin(xi,yi,xf,yf)\
  228.      crtwin_dta.left=xi;\
  229.      crtwin_dta.top=yi;\
  230.      crtwin_dta.right=xf;\
  231.      crtwin_dta.bottom=yf    //easely loads values to crtwin_dta
  232.  
  233.     //crtwindow macros
  234. #define janela(p0)\
  235.     p0.btype=0;\
  236.     crtwindow(p0)    //draws a window with single outline
  237. #define janelad(p0)\
  238.     p0.btype=1;\
  239.     crtwindow(p0)    //draws a window with double outline
  240.  
  241. #endif /* __CRT_H */
  242.  
  243. // By Márcio Afonso Arimura Fialho.
  244. // Email: jlfialho@inconet.com.br OR jlfialho@yahoo.com.br (alternate)
  245. // http://pessoal.iconet.com.br/jlfialho
  246. // Freeware Library Functions - Free Distribution and Use.
  247. // Read README.1ST for information.